package org.erp.store.infrastructure.enums;

import org.erp.common.enums.DeviceInventoryEvent;

/**
 * 需要MQ通知的事件类型枚举
 * 用于配置哪些事件需要发送MQ消息通知
 * 
 * @author dingding
 * @since 2025-11-19
 */
public enum MqNotificationEvent {
    
    /** 再次入库（驳回或返库后） */
    REJECT_TO_INBOUND(DeviceInventoryEvent.REJECT_TO_INBOUND, "再次入库事件"),
   

    /** 返库再次入库 */
    RETURN_TO_INBOUND(DeviceInventoryEvent.RETURN_TO_INBOUND, "返库再次入库事件"),
    
    /** 确认退库完成 */
    CONFIRM_REFUND(DeviceInventoryEvent.CONFIRM_REFUND, "确认退库完成事件");

    

    
    private final DeviceInventoryEvent deviceEvent;
    private final String description;
    
    MqNotificationEvent(DeviceInventoryEvent deviceEvent, String description) {
        this.deviceEvent = deviceEvent;
        this.description = description;
    }
    
    public DeviceInventoryEvent getDeviceEvent() {
        return deviceEvent;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 判断指定的事件是否需要MQ通知
     */
    public static boolean isNotificationRequired(DeviceInventoryEvent event) {
        if (event == null) {
            return false;
        }
        for (MqNotificationEvent notificationEvent : MqNotificationEvent.values()) {
            if (notificationEvent.getDeviceEvent() == event) {
                return true;
            }
        }
        return false;
    }
    
    /**
     * 根据设备事件获取MQ通知事件
     */
    public static MqNotificationEvent getByDeviceEvent(DeviceInventoryEvent event) {
        if (event == null) {
            return null;
        }
        for (MqNotificationEvent notificationEvent : MqNotificationEvent.values()) {
            if (notificationEvent.getDeviceEvent() == event) {
                return notificationEvent;
            }
        }
        return null;
    }
}